<template>
  <el-row class="inventory-info">
    <el-col :span="8">
      <label>{{$t('m.inventory.type')}}</label>
      <el-input size="small" v-model="inventoryStockType" disabled></el-input>
    </el-col>

    <template v-if="[4,5].includes(stocktype)">
      <el-col :span="8">
        <label>{{remarkTitle}}</label>
        <el-input size="small" v-model="remarkTips" disabled></el-input>
      </el-col>
    </template>

    <el-col :span="8">
      <label>{{$t('m.inventory.method')}}</label>
      <el-input size="small" v-model="inventoryStockWay" disabled></el-input>
    </el-col>

  </el-row>
</template>
<script>
export default {
  name:'inventory-form-brief',
  data(){
    return {
      form:{},
      stocktype:0, // 盘点类型
      stocktypeOptions:[], // 盘点类型options
      stockwayOptions:[], // 盘点方式options

      warningNum:'<小于200', //预警数量
      warehouseAge:'>大于180天', //库龄
      remarkTitle:'',
      remarkTips:''
    }
  },
  inject:{
    getFormInfo:{
      default:()=>{}
    },
    getStockOptions:{
      default:()=>[]
    },
    getInventoryDetail:{
      default:()=>{}
    }
  },
  mounted(){
    this.stocktype = this.getInventoryDetail()?this.getInventoryDetail().stocktype:this.getFormInfo().stocktype
    let [stocktypeOptions,stockwayOptions] = this.getStockOptions()
    this.stocktypeOptions = stocktypeOptions
    this.stockwayOptions = stockwayOptions
    // console.log(this.getStockOptions())
    if([4,5].includes(this.stocktype)){
      let {remark} = this.stocktypeOptions.find((item)=>item.value === this.stocktype)
      this.remarkTitle = remark.split(':')[0].substring(1)
      if(!this.getInventoryDetail()){
        this.remarkTips = remark.split(':')[1].slice(0,-1)
      }else{
        this.remarkTips = this.getInventoryDetail().condition
      }
    }

    // 新增功能
    if(!this.getInventoryDetail()) this.form = this.getFormInfo()
  },
  computed:{
    inventoryStockType(){
      let stocktype = this.getInventoryDetail()?this.getInventoryDetail().stocktype:this.form.stocktype
      if(this.stocktypeOptions.length){
        return this.stocktypeOptions.find((item)=>{
          return item.value === stocktype
        }).label
      }
      return ''
    },
    inventoryStockWay(){
      let stockway = this.getInventoryDetail()?this.getInventoryDetail().stockway:this.form.stockway
      if(this.stockwayOptions.length){
        return this.stockwayOptions.find((item)=>{
          return item.value === stockway
        }).label
      }
      return ''
    }
  },
  methods:{

  }
}
</script>
<style lang="scss" scoped>
.inventory-info{
  label{margin-right: 10px;}
  .el-input{width: 70%;}
}
</style>